package it.koutifaris.travianmap.dal.sqlservices.mapuiservice;

import it.koutifaris.travianmap.dal.MapUIService.MapViewState;

public class MapViewStateImpl implements MapViewState {

	private final int x;
	private final int y;
	private final float zoom;

	private static final MapViewStateImpl INITIAL_STATE = new MapViewStateImpl(0, 0, 1);

	public MapViewStateImpl(int x, int y, float zoom) {
		this.x = x;
		this.y = y;
		this.zoom = zoom;
	}

	public static MapViewStateImpl initialState() {
		return INITIAL_STATE;
	}

	@Override
	public int getX() {
		return x;
	}

	@Override
	public int getY() {
		return y;
	}

	@Override
	public float getZoom() {
		return zoom;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		result = prime * result + Float.floatToIntBits(zoom);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof MapViewStateImpl))
			return false;
		MapViewStateImpl other = (MapViewStateImpl) obj;
		if (x != other.x)
			return false;
		if (y != other.y)
			return false;
		if (Float.floatToIntBits(zoom) != Float.floatToIntBits(other.zoom))
			return false;
		return true;
	}

}
